﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApp01_7
{
    public partial class AddTask : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            var taskName = TextBox1.Text;
            var taskConnent = TextBox2.Text;
            var remarks = TextBox3.Text;

            var user = (SortedList<string, string>)Session["userInfor"];
            string s = "select * from Users where Username='" + user["userName"] + "'";
            var id = (int)DbHelper.GetData(s).Rows[0].ItemArray[0];



            string sql = string.Format("insert into Task(TaskName,TaskContent,CreatedUserId,Remarks) values('{0}','{1}','{2}','{3}')",taskName,taskConnent,id,remarks);

            
            var res=DbHelper.UpdateData(sql);

            if (res > 0)
            {
                Response.Redirect("Default.aspx?cancel=true");
            }
        }
        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx?cancel=true");
        }
    }
}